package cn.com.generaldata.os.ws.test;

import static org.junit.Assert.*;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.nutz.json.Json;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;

import cn.com.generaldata.jsme_indicator_system.util.Constants;
import cn.com.generaldata.os.result.IndicatorProvinceCategoryWSResult;
import cn.com.generaldata.os.vo.IndicatorProvinceVO;
import cn.com.generaldata.os.vo.IndicatorStatQueryVO;
import cn.com.generaldata.os.ws.intf.IndicatorStatWSInterface;

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "/applicationContext-soap-client.xml" })
public class IndicatorStatWebServiceClient {

	@Autowired
	private IndicatorStatWSInterface indicatorStatWSInterface;

	@Test
	public void testIndicatorStat() {
		IndicatorStatQueryVO queryVO = new IndicatorStatQueryVO();
		queryVO.setProvinceId("320000000000000");
		queryVO.setFrequency(2);
		queryVO.setYear(2018);
		queryVO.setQuarter(4);
		queryVO.setDatasource(Constants.INDICATOR_DATASOURCE_ADMIN);
		queryVO.setFirstIndicatorCodePrefix("Ⅱ01");
		String result = Json.toJson(indicatorStatWSInterface.indicatorStat(queryVO));
		System.out.println(result);
	}

	@Test
	public void testGetIndicatorCategory() {
		IndicatorProvinceCategoryWSResult result = null;
		result = indicatorStatWSInterface.getIndicatorCategory(null);
		assertEquals(5, result.getIndicators().size());

		IndicatorProvinceVO vo = result.getIndicators().get(0);

		result = indicatorStatWSInterface.getIndicatorCategory(vo.getId());

		assertTrue(result.getIndicators().size() > 0);
	}
}
